import 'dart:convert';
import 'dart:typed_data';

import 'package:bot_toast/bot_toast.dart';
import 'package:dio/dio.dart';
import 'package:exams_app/gen_a/A.dart';

import 'package:exams_app/net/DioManager.dart';
import 'package:exams_app/net/persisten_storage.dart';
import 'package:exams_app/widget/hexcolor.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_image_compress/flutter_image_compress.dart';
import 'package:get/get.dart';

import '../logic.dart';
import 'logic.dart';

import 'dart:io';
import 'package:exams_app/home_module/account_set_module/account_logic.dart';
import 'package:common_utils/common_utils.dart';

// class RealNameAuthenPage extends StatefulWidget {
//   @override
//   _RealNameAuthenPageState createState() => _RealNameAuthenPageState();
// }

class RealNameAuthenPage extends StatelessWidget {


  final RealNameAuthenLogic logic = Get.put(RealNameAuthenLogic());

  final AccountLogic homeLogic = Get.put(AccountLogic());


/*
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    homeLogic.requestDataWithUserInfo();
  }
*/



  @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          centerTitle: true,
          title: Text('实名认证'),
        ),
        body: GetBuilder<RealNameAuthenLogic>(
          initState: (as){


          },
          builder: (logic) {

        return ListView(
          children: [


            Container(
                height: 50,
                decoration: new BoxDecoration(
                  color: Colors.white,
                  //设置四周圆角 角度
                  borderRadius: BorderRadius.all(Radius.circular(22.0)),
                  //设置四周边框
                  border: new Border.all(width: 1, color: HexColor('#ECECEC')),

                ),
                padding: EdgeInsets.only(left: 15),
                margin: EdgeInsets.only(top: 50,left: 15,right: 0),
                // width: Get.width-100,
                child: Row(
                  children: [
                    Container(
                      margin: EdgeInsets.only(right: 5),
                      child: Text('项目名称',style: TextStyle(fontSize: 16,color: HexColor('#333333')),),
                    ),

                    VerticalDivider(
                      indent: 10,
                      endIndent: 10,
                      color: HexColor('#DFDFDF'),
                      width: 2,
                    ),
                    Container(
                      margin: EdgeInsets.only(left: 5),
                      width: Get.width-150,
                      child: TextField(
                        inputFormatters: [
                          // LengthLimitingTextInputFormatter(16)
                        ],
                        controller: logic.tf3,
                        style: TextStyle(fontSize: 16),
                        decoration: InputDecoration(

                          // isCollapsed: true,
                          // contentPadding: EdgeInsets.only(top: 15),
                          hintText: '请输入项目名称',
                          hintStyle: TextStyle(fontSize: 16,color: HexColor('#BBBBBB')),
                          border: InputBorder.none,
                          // prefixIcon: Image.asset(A.assets_user,),
                        ),
                      ),
                    )
                  ],
                )
            ),
            Container(
                height: 50,
                decoration: new BoxDecoration(
                  color: Colors.white,
                  //设置四周圆角 角度
                  borderRadius: BorderRadius.all(Radius.circular(22.0)),
                  //设置四周边框
                  border: new Border.all(width: 1, color: HexColor('#ECECEC')),

                ),
                padding: EdgeInsets.only(left: 15),
                margin: EdgeInsets.only(top: 25,left: 15,right: 0),
                // width: Get.width-100,
                child: Row(
                  children: [
                    Container(
                      margin: EdgeInsets.only(right: 5),
                      child: Text('公司名称',style: TextStyle(fontSize: 16,color: HexColor('#333333')),),
                    ),

                    VerticalDivider(
                      indent: 10,
                      endIndent: 10,
                      color: HexColor('#DFDFDF'),
                      width: 2,
                    ),
                    Container(
                      margin: EdgeInsets.only(left: 5),
                      width: Get.width-150,
                      child: TextField(
                        inputFormatters: [
                          // LengthLimitingTextInputFormatter(15)
                        ],
                        controller: logic.tf4,
                        style: TextStyle(fontSize: 16),
                        decoration: InputDecoration(
                          // isCollapsed: true,
                          // contentPadding: EdgeInsets.only(top: 15),
                          hintText: '请输入公司名称',
                          hintStyle: TextStyle(fontSize: 16,color: HexColor('#BBBBBB')),
                          border: InputBorder.none,
                          // prefixIcon: Image.asset(A.assets_user,),
                        ),
                      ),
                    )
                  ],
                )
            ),

            Container(
                height: 50,
                decoration: new BoxDecoration(
                  color: Colors.white,
                  //设置四周圆角 角度
                  borderRadius: BorderRadius.all(Radius.circular(22.0)),
                  //设置四周边框
                  border: new Border.all(width: 1, color: HexColor('#ECECEC')),

                ),
                padding: EdgeInsets.only(left: 15),
                margin: EdgeInsets.only(top: 25,left: 15,right: 0),
                // width: Get.width-100,
                child: Row(
                  children: [
                    Container(
                      margin: EdgeInsets.only(right: 5),
                      child: Text('真实姓名',style: TextStyle(fontSize: 16,color: HexColor('#333333')),),
                    ),

                    VerticalDivider(
                      indent: 10,
                      endIndent: 10,
                      color: HexColor('#DFDFDF'),
                      width: 2,
                    ),
                    Container(
                      margin: EdgeInsets.only(left: 5),
                      width: Get.width-200,
                      child: TextField(
                        inputFormatters: [
                          LengthLimitingTextInputFormatter(7)
                        ],
                        controller: logic.tf1,
                        style: TextStyle(fontSize: 16),
                        decoration: InputDecoration(
                          // isCollapsed: true,
                          // contentPadding: EdgeInsets.only(top: 15),
                          hintText: '请输入您真实姓名',
                          hintStyle: TextStyle(fontSize: 16,color: HexColor('#BBBBBB')),
                          border: InputBorder.none,
                          // prefixIcon: Image.asset(A.assets_user,),
                        ),
                      ),
                    ),


                  ],
                )
            ),
            Container(
                height: 50,
                decoration: new BoxDecoration(
                  color: Colors.white,
                  //设置四周圆角 角度
                  borderRadius: BorderRadius.all(Radius.circular(22.0)),
                  //设置四周边框
                  border: new Border.all(width: 1, color: HexColor('#ECECEC')),

                ),
                padding: EdgeInsets.only(left: 15),
                margin: EdgeInsets.only(top: 20,left: 15,right: 0),
                // width: Get.width-100,
                child: Row(
                  children: [
                    Container(
                      margin: EdgeInsets.only(right: 5),
                      child: Text('身份证号',style: TextStyle(fontSize: 16,color: HexColor('#333333')),),
                    ),

                    VerticalDivider(
                      indent: 10,
                      endIndent: 10,
                      color: HexColor('#DFDFDF'),
                      width: 2,
                    ),
                    Container(
                      margin: EdgeInsets.only(left: 5),
                      width: Get.width-150,
                      child: TextField(
                        controller: logic.tf2,
                        style: TextStyle(fontSize: 16),
                        decoration: InputDecoration(
                          // isCollapsed: true,
                          // contentPadding: EdgeInsets.only(top: 15),
                          hintText: '请输入身份证号码',
                          hintStyle: TextStyle(fontSize: 16,color: HexColor('#BBBBBB')),
                          border: InputBorder.none,
                          // prefixIcon: Image.asset(A.assets_user,),
                        ),
                      ),
                    )
                  ],
                )
            ),

            Container(
              margin: EdgeInsets.only(top: 25,left: 20),
              child: Text('上传身份证',style: TextStyle(fontSize: 18,color: HexColor('#333333'),fontWeight: FontWeight.w500),),
            ),
            Obx(() {
            return Container(
            margin: EdgeInsets.only(top: 15,right: 10,left: 15),
            child: Row(
              children: [
                Expanded(
                  child:  GestureDetector(
                    onTap:logic.onClickUpCardHeader,
                    child: Column(
                      children: [
                        Container(
                          padding: EdgeInsets.only(right: 5),
                          width: 200,
                          height: 100,
                          child: logic.imagePath1.value==''?Image.asset(A.assets_zhengmianid):Image.file(File(logic.imagePath1.value),fit: BoxFit.contain,),
                        ),
                        Text('请上传身份证正面照')
                      ],
                    ),
                  ),
                ),
                Expanded(
                    child:GestureDetector(
                      onTap: logic.onClickUpCardFoot,
                      child:Column(
                        children: [
                          Container(
                            width: 170,
                            height: 100,
                            child: logic.imagePath2.value==''?Image.asset(A.assets_beimianid):Image.file(File(logic.imagePath2.value)),
                          ),
                          Text('请上传身份证反面照')
                        ],
                      ),
                    )
                ),

              ],
            ),
          );
}),

            Container(
              margin: EdgeInsets.only(top: 100, right: 25, left: 25),
              width: Get.width,
              height: 45,
              child:
              RaisedButton(
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(22),
                ),
                color: Theme.of(context).primaryColor,
                onPressed: logic.onClickNextMthod,
                child: Text(
                  '下一步',
                  style: TextStyle(color: Colors.white),
                ),
              ),
            ) ,
          ],

        );
  },
),
      );
    }




}

